$input a_color0, a_position
$output basecolor, horizioncolor, worldpos

#include <bgfx_shader.sh>
#include <Fuctions_MLYX.glsl>

uniform vec4 FogColor;
uniform vec4 FogAndDistanceControl;

void main(){

#if defined(OPAQUE)

    vec3 skypos = a_position;
    skypos.y -= 0.15*a_color0.r*a_color0.r;
    vec3 Position = skypos.xyz;
    Position.y += 0.148;
    bool InsuperiAquoris = FogAndDistanceControl.x==0.0&&FogAndDistanceControl.y<0.8&&(FogColor.b>FogColor.r||FogColor.g>FogColor.r);

    if(InsuperiAquoris){
        basecolor = vec3(0.2,0.3,0.5);
        horizioncolor = vec3(0.2,0.3,0.5);
    } else {
        float LloverDet = ViaALlover(FogAndDistanceControl.xyz);
        basecolor = CaeloBasic(LloverDet, FogColor.rgb);
        horizioncolor = CaeloHorizionte(LloverDet, FogColor.rgb);
    }

    worldpos = Position;
    gl_Position = mul(u_modelViewProj, vec4(skypos, 1.0));

#else
    gl_Position = vec4(0.0,0.0,0.0,0.0);
#endif

}